﻿namespace Vcare.Controllers
{
  using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using Vcare.Models;
  using Vcare.DAL;
  using System.IO;
  using System.Web.Security;
  using System.Data.Entity.Validation;
  using Vcare.Helpers;

    public class OperationsController : Controller
    {
      private VcareContext db = new VcareContext();

      public ActionResult MembersReport()
      {
        CallCentresController cc = new CallCentresController();
        Guid callcentreid = cc.GetID();
        return Redirect("http://webellas.arvixevps.com/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fvcarereports%2fMainMember&rs:Command=Render");
      }

      public ActionResult SalesReport()
      {
        CallCentresController cc=new CallCentresController();
        Guid callcentreid = cc.GetID();
        return Redirect("http://webellas.arvixevps.com/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fvcarereports%2fSalesReport&rs:Command=Render");
      }

      public ActionResult DDReport()
      {
        CallCentresController cc=new CallCentresController();
        Guid callcentreid = cc.GetID();
        return Redirect("http://webellas.arvixevps.com/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fvcarereports%2fDD&rs:Command=Render");
      }

      public ActionResult OgoneReport()
      {
        CallCentresController cc=new CallCentresController();
        Guid callcentreid = cc.GetID();
        return Redirect("http://webellas.arvixevps.com/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fvcarereports%2fOgone&rs:Command=Render");
      }

      public ActionResult CheckScrubbed()
      {
        CallCentresController cc=new CallCentresController();
        Guid callcentreid = cc.GetID();
        return Redirect("http://webellas.arvixevps.com/ReportServer_SQLEXPRESS/Pages/ReportViewer.aspx?%2fvcarereports%2fScrubbed&rs:Command=Render");
      }
      
      public ActionResult Processed(DateTime startofperiod, DateTime endofperiod)
      {
        foreach (Members member in db.Members.Where(m => m.ContactDate>=startofperiod && m.ContactDate<=endofperiod))
        {
          member.Processed=true;
          member.DateUpdated = DateTime.Now;
          db.Entry(member).State=EntityState.Modified;
        }
        db.SaveChanges();
        return View();
      }

    }
}
